<template>
  <div class="row">
    <div v-for="column in columnList" :key="column.id" class="col-4 mb-4">
      <div class="card h-100 shadow-sm">
        <div class="card-body text-center">
          <img
            :src="column.img"
            class="rounded-circle border border-light my-3"
            :alt="column.title"
            width="100"
            height="100"
          />
          <h5 class="card-title">{{ column.title }}</h5>
          <p class="card-text text-left">{{ column.summary }}</p>
          <router-link
            :to="`/column/${column.columnId}/${column.id}`"
            class="btn btn-outline-primary"
            >查看</router-link
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script lang='ts'>
import { computed, defineComponent, PropType } from "vue";
import { ColumnProps } from '../store'
export default defineComponent({
  name: "ColumnList",
  props: {
    list: {
      type: Array as PropType<ColumnProps[]>,
      required: true,
    },
  },
  setup(props) {
    const columnList = computed(() => {
      return props.list.map((column) => {
        // console.log(column)
        if (!column.img) {
          column.img = {
            url: require("@/assets/column.jpg")
          }
        }
        return column;
      });
    });
    return {
      columnList,
    };
  },
});
</script>

<style lang="" scoped>
</style>
